package com.study.account.ui.fragment

import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.Fragment
import com.blankj.utilcode.util.SPUtils
import com.study.account.BuildConfig
import com.study.account.R
import kotlinx.android.synthetic.main.fragment_login.*
import org.jetbrains.anko.sdk27.coroutines.onClick

/**
 * <pre>
 *     author : fauks
 *     time   : 2020/03/23
 *     desc   :
 * </pre>
 */
class LoginFragment : Fragment() {
    override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
        return inflater.inflate(R.layout.fragment_login, container, false)
    }

    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
        super.onViewCreated(view, savedInstanceState)
        val username = accountUsername.text?.trim().toString()
        val password = accountPwd.text?.trim().toString()
        accountLogin.onClick {
            if (username == BuildConfig.username && password == BuildConfig.passwrod) {
                //登录成功
                SPUtils.getInstance().put("isLogin", true)
                SPUtils.getInstance().put("userId", "1001")
            }
        }
    }
}